<?php
/**
 * @author 	 	 faithsmine@gmail.com
 * @copyright		 ourmy.com
 * @version		 1.0
 * @name 		 index.php
 * @todo 		 show shops of credit crown 
 * @final 		 2010-06-01
 */
define('IN_YCTOOL', true);//定义该文件合法性
require_once('config.php');
require_once('config2.php');

require_once(DIR_COMM . 'common.php');
require_once DIR_COMM.'template.func.php';
$header_shops = db::getLeftJoin('tao_shops','tao_crown_users','*','a.nick=b.nick','1 ORDER BY b.score DESC LIMIT 10');

$pcats = db::getAll('tao_shopcats','*','ispid=1');
$scats = db::getAll('tao_shopcats','*','ispid=0');
 
$catss = array(); 
foreach($scats as $k=>$v)
{
    $catss[$v['cid']] = $v['name'];
    $catss2[$v['name']] = $v['cid'];
}
 
$sitetitle = '淘频道';
$loctitle = '淘宝网皇冠店铺大全';
$keywords = '淘宝网皇冠店铺大全,淘宝皇冠店铺,淘宝皇冠,淘宝皇冠店';
$description = '提供淘宝皇冠店铺大全及淘宝商城卖家大全，精细挑选，让你在淘宝网购物更放心更方便';
$v1 = '1.1.20100512a';
include('./admin/util.php');
if($_GET['go'] == 'huangguan')
{
    
}else if($_GET['go'] == 'shop')
{
    $v1 = '0.1.20100521a';  
    $sid = $_GET['sid'];
    db::query('UPDATE tao_shops SET vcount=vcount+1 WHERE sid='.$sid);
    $shopinfo = db::getLeftJoin('tao_shops','tao_crown_users','*','a.nick=b.nick', 'a.sid='.$sid);
    $pic_path = $shopinfo[0]['pic_path'];
    $sname =  $shopinfo[0]['shop_title'] ;
    $snick = $shopinfo[0]['nick'];
    $total_num = $shopinfo[0]['total_num'];
    $good_num = $shopinfo[0]['good_num'];
    $catname = $catss[$shopinfo[0]['ccid']];
    $loctitle = $sname .'_'.$catname.'_淘宝网皇冠店';
    $desc = $shopinfo[0]['title'];
    $vcount = $shopinfo[0]['vcount'];
    !$vcount&&$vcount=0;
    $commcount = db::getOne('tao_scomm','count(*)','ctype=1 and sid='.$sid);
    $tjcount = db::getOne('tao_scomm','count(*)','ctype=2 and sid='.$sid);
    $jbcount = db::getOne('tao_scomm','count(*)','ctype=3 and sid='.$sid);
 
    $newstored = db::getLimit('tao_shops','*','ORDER BY storetime DESC LIMIT5');
            $url = 'http://gw.api.taobao.com/router/rest?';
            $appKey = $cfg_tbk['appkey'];  
            $appSecret = $cfg_tbk['appkecret'];  
            $userNick =$cfg_tbk['usernick']; //淘宝昵称
            $paramArr = array(
            'app_key'   => $appKey, 
            'method'    => 'taobao.items.search', 
            'format'    => 'xml', 
            'v'         => '2.0', 
            'timestamp' => date('Y-m-d H:i:s'), 
            'fields'    => 'iid,num_iid,title,pic_url,nick,price,volume',
            'nick'      => $userNick,
            'nicks'      => $snick,         
            'sort'      => 'commissionNum_desc',
            'page_size' => '8',
            'page_no' => '1',
            'sign_method'=>'HmacMD5' //选择md5方式的时候,这行注释掉
        //	'sign_method'=>'md5', //选择Hmac方式的时候,这行注释掉	
            );
 
        //生成签名
            $sign = createSign($paramArr,$appSecret);
 
        //组织参数
            $strParam = createStrParam($paramArr);
            $strParam .= 'sign='.$sign;
//访问服务
            $url = $url.$strParam;
         
            $result = file_get_contents($url);
            $result = getXmlData($result);
           //print_r($result); 
            $spros = $result['item_search']['items']['item'];
            !$spros && $spros = array();
            foreach($spros as $k=>$v)
            {
                $iids[$k] = $v['iid'];
            } 
            $iids = implode(',',$iids);
         
                $url = 'http://gw.api.taobao.com/router/rest?';
                $appKey = $cfg_tbk['appkey'];  
                $appSecret = $cfg_tbk['appkecret'];  
                $userNick =$cfg_tbk['usernick']; //淘宝昵称
            $paramArr = array(
                'app_key'   => $appKey, 
                'method'    => 'taobao.taobaoke.items.convert', 
                'format'    => 'xml', 
                'v'         => '2.0', 
                'timestamp' => date('Y-m-d H:i:s'), 
                'fields'    => 'iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume',
                'nick'      => $userNick,
                'iids'      => $iids, 
                'sign_method'=>'HmacMD5' //选择md5方式的时候,这行注释掉
            //	'sign_method'=>'md5', //选择Hmac方式的时候,这行注释掉	
            );
 
        //生成签名
                $sign = createSign($paramArr,$appSecret);
 
        //组织参数
                $strParam = createStrParam($paramArr);
                $strParam .= 'sign='.$sign;
//访问服务
                $url = $url.$strParam;
                $result = file_get_contents($url);
                $result = getXmlData($result); 
                $sitems = $result['taobaoke_items']['taobaoke_item'];
                //最新收录店铺
                
                $latests = db::getAll('tao_shops','*','1 ORDER BY storetime DESC LIMIT 10');
                //同类店铺
                $samecats = db::getAll('tao_shops','*','cid='.$shopinfo[0]['ccid'].' ORDER BY storetime DESC LIMIT 10');
                //热门店铺

    require_once tpl('shop.html');
    exit;
}
//最近浏览
//旗舰店
$ships = db::getAll('tao_shops','*','shop_title like \'%旗舰店%\' LIMIT 8');
//首页分类
$girlssuit = db::getAll('tao_shops','*','cid='.$catss2['女装'].' LIMIT 6');
$boyssuit = db::getAll('tao_shops','*','cid='.$catss2['男装'].' LIMIT 6');
$innersuit = db::getAll('tao_shops','*','cid='.$catss2['男女内衣'].' LIMIT 6');
$childsuit = db::getAll('tao_shops','*','cid='.$catss2['童装'].' LIMIT 6');
$extusuit = db::getAll('tao_shops','*','cid='.$catss2['服饰配件'].' LIMIT 6');
$colortool = db::getAll('tao_shops','*','cid='.$catss2['彩妆工具'].' LIMIT 6');
$decorats = db::getAll('tao_shops','*','cid='.$catss2['化妆品'].' LIMIT 6');
$girlshoes = db::getAll('tao_shops','*','cid='.$catss2['女鞋'].' LIMIT 6');
$boyshoes = db::getAll('tao_shops','*','cid='.$catss2['男鞋'].' LIMIT 6');
$sportshoes = db::getAll('tao_shops','*','cid='.$catss2['运动鞋'].' LIMIT 6');
$bags = db::getAll('tao_shops','*','cid='.$catss2['箱包皮具'].' LIMIT 6');
$litshipin = db::getAll('tao_shops','*','cid='.$catss2['饰品'].' LIMIT 6');
$handwatch = db::getAll('tao_shops','*','cid='.$catss2['手表'].' LIMIT 6');
$juwery = db::getAll('tao_shops','*','cid='.$catss2['珠宝'].' LIMIT 6');
$dailyuse = db::getAll('tao_shops','*','cid='.$catss2['居家日用'].' LIMIT 6');
$beds = db::getAll('tao_shops','*','cid='.$catss2['床品布艺'].' LIMIT 6');
 $applias = db::getAll('tao_shops','*','cid='.$catss2['家用电器'].' LIMIT 6');
$furniture = db::getAll('tao_shops','*','cid='.$catss2['家具'].' LIMIT 6');
  $homedec = db::getAll('tao_shops','*','cid='.$catss2['家饰'].' LIMIT 6');
$decoration = db::getAll('tao_shops','*','cid='.$catss2['装潢'].' LIMIT 6');
  $workout = db::getAll('tao_shops','*','cid='.$catss2['运动健身'].' LIMIT 6');
$outhike = db::getAll('tao_shops','*','cid='.$catss2['户外涉水'].' LIMIT 6');
 $personal = db::getAll('tao_shops','*','cid='.$catss2['个人护理'].' LIMIT 6');
$prohelthy = db::getAll('tao_shops','*','cid='.$catss2['保健品'].' LIMIT 6') ;
$cellphone = db::getAll('tao_shops','*','cid='.$catss2['手机'].' LIMIT 6');
 $digital = db::getAll('tao_shops','*','cid='.$catss2['数码摄像'].' LIMIT 6');
$mp34 = db::getAll('tao_shops','*','cid='.$catss2['MP3_MP4'].' LIMIT 6') ;
$handpad = db::getAll('tao_shops','*','cid='.$catss2['笔记本'].' LIMIT 6') ;
$hardware = db::getAll('tao_shops','*','cid='.$catss2['电脑硬件'].' LIMIT 6');
$digtal3c = db::getAll('tao_shops','*','cid='.$catss2['3C数码'].' LIMIT 6');
$mobstore = db::getAll('tao_shops','*','cid='.$catss2['移动存储'].' LIMIT 6') ;
$electoys = db::getAll('tao_shops','*','cid='.$catss2['电玩'].' LIMIT 6');
$mumbaby = db::getAll('tao_shops','*','cid='.$catss2['母婴用品'].' LIMIT 6') ;
$babytoy = db::getAll('tao_shops','*','cid='.$catss2['玩具'].' LIMIT 6');
$zippo = db::getAll('tao_shops','*','cid='.$catss2['ZIPPO'].' LIMIT 6') ;
$oldthing = db::getAll('tao_shops','*','cid='.$catss2['古董'].' LIMIT 6');
$videom = db::getAll('tao_shops','*','cid='.$catss2['影视音乐'].' LIMIT 6') ;
$books = db::getAll('tao_shops','*','cid='.$catss2['书籍'].' LIMIT 6');
$food = db::getAll('tao_shops','*','cid='.$catss2['食品'].' LIMIT 6') ;
$gflower = db::getAll('tao_shops','*','cid='.$catss2['园艺花卉'].' LIMIT 6') ;


require_once tpl('index.html');
exit();
?>

